<%@page import="edu.scau.hibernate.model.User"%>
<%@page import="edu.scau.hibernate.service.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" errorPage="error.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>login</title>
</head>
<body>
     <!--用户登录检测  -->
     <%UserService serviceImpl = new UserServiceImpl();
       User user = null;
       user = serviceImpl.findUserByUserName(request.getParameter("userName"));
       if(user==null){
    	   throw new NullPointerException("用户不存在！");
    	   }
       else if(!(user.getPassword().equals(request.getParameter("pwd")))){
    	  throw new Error("密码错误！");
       }
       else{
    	   response.sendRedirect("index.jsp");
    	   session.setAttribute("user", user);
       }
     %>
</body>
</html>
